package com.common.www.bean.entity.project;

import org.springframework.boot.base.jpa.domain.annotations.QueryCacheable;
import org.springframework.boot.base.jpa.domain.entity.NumberIdentityEntity;
import com.common.www.bean.entity.tabulation.*;
import com.common.www.bean.vo.StatisticalBiddingVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import lombok.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Map;

/**
 * 招投标参与单位信息
 *
 * @param
 * @author andyliu
 * @date 5/28/2018 4:23 PM
 * @return
 */
@DynamicUpdate(true)
@DynamicInsert(true)
@Entity
@Getter
@Setter
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table()
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "招投标参与单位信息")
public class BiddingCompany extends NumberIdentityEntity {
    /**
     * 参与项目
     */
    @JsonIgnoreProperties(value = {""})
    @ManyToOne()
    private Project project;
    /**
     * 供应公司
     */
    @JsonIgnoreProperties(value = {""})
    @ManyToOne()
    private SupplyCompany supplyCompany;

    /**
     * 内线或外线信息；1.内线 2.外线
     */
    @Column(length = 11)
    private Integer innerOuterType;
    /**
     * 淘汰供应商时需要选择在哪个阶段被淘汰的
     * 参加阶段；1.标底 2.回标1 3.回标2 4.回标3 5.回标4 6.定标 7.实施标底 8.实施定标
     */
    @Column(length = 11)
    private String weedOutJieDuan;
    /**
     * 供应商标状态；1.正常 2.弃标 3.淘汰
     */
    @Column(length = 11)
    private Integer bidStatus;
    /**
     * 备注
     */
    @Column(length = 4096)
    @Length(max=4096,message = "备注最长不超过4096位")
    private String remarks;


    @Transient
    private String bidStatusName;

    public String getBidStatusName() {
        if (bidStatus == null) {
            return "未知";
        }
        switch (bidStatus) {
            case 1:
                return "正常";
            case 2:
                return "弃标";
            case 3:
                return "淘汰";
        }
        return "未知";
    }



    //===============================

    /**
     * 内线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo innerTabulation1;
    /**
     * 内线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo innerTabulation2;
    /**
     * 内线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo innerTabulation3;
    /**
     * 内线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo innerTabulation4;
    /**
     * 内线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo innerTabulation5;
    /**
     * 内线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo innerTabulation6;
    /**
     * 内线清单 标底
     */
    @JsonIgnoreProperties(value = {""})
    @Transient
    private Map<String, Object> innerBidBaseTabulation1;
    /**
     * 内线清单 实施标底
     */
    @JsonIgnoreProperties(value = {""})
    @Transient
    private Map<String, Object> innerBidBaseTabulation2;


    /**
     * 外线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo outerTabulation1;
    /**
     * 外线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo outerTabulation2;
    /**
     * 外线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo outerTabulation3;
    /**
     * 外线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo outerTabulation4;
    /**
     * 外线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo outerTabulation5;
    /**
     * 外线清单
     */
    @JsonIgnoreProperties(value = {"biddingCompany"})
    @Transient
    private StatisticalBiddingVo outerTabulation6;
    /**
     * 外线清单 标底
     */
    @JsonIgnoreProperties(value = {""})
    @Transient
    private Map<String, Object> outerBidBaseTabulation1;
    /**
     * 外线清单 实施标底
     */
    @JsonIgnoreProperties(value = {""})
    @Transient
    private Map<String, Object> outerBidBaseTabulation2;
}